import request from '@/axios'
import { CourseParams, CourseResponse, KindParams, KindResponse } from './types'

export const getCourseApi = (params: CourseParams) => {
  return request.get<CourseResponse>({ url: '/course/list', params })
}

export const deleteCourseByIdApi = (ids: string[] | number[]) => {
  return request.delete({ url: '/course/delete', data: { ids } })
}

export const saveCourseApi = (data: any) => {
  return request[data.id ? 'put' : 'post']({
    url: data.id ? '/course/edit' : '/course/add',
    data
  })
}

export const getKindApi = (params: KindParams) => {
  return request.get<KindResponse>({ url: '/course/kind', params })
}

export const deleteKindByIdApi = (ids: string[] | number[]) => {
  return request.delete({ url: '/course/kindDelete', data: { ids } })
}

export const saveKindApi = (data: any) => {
  return request[data.id ? 'put' : 'post']({
    url: data.id ? '/course/kindEdit' : '/course/kindAdd',
    data
  })
}
